package com.example.agriculture.service.impl;

import com.example.agriculture.dao.OrderFormDao;
import com.example.agriculture.entity.OrderForm;
import com.example.agriculture.service.OrderFormService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (OrderForm)表服务实现类
 *
 * @author makejava
 * @since 2022-09-12 23:20:24
 */
@Service("orderFormService")
public class OrderFormServiceImpl implements OrderFormService {
    @Resource
    private OrderFormDao orderFormDao;


//    @Override
//    public List<OrderForm> countLimit(int offset, int limit, int userid) {
//        return orderFormDao.countLimit(offset,limit,userid) ;
//    }


    @Override
    public List<OrderForm> queryAllToLimit( int offset, int limit,int id) {
        return orderFormDao.queryAllToLimit(offset,limit,id);
    }
    @Override
    public List<OrderForm> countAllLimit(int offset, int limit, int keyword) {
        return orderFormDao.countAllLimit(offset,limit,keyword);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param orderId 主键
     * @return 实例对象
     */
    @Override
    public OrderForm queryById(Integer orderId) {
        return this.orderFormDao.queryById(orderId);
    }
    @Override
    public List<OrderForm> queryByUserId(Integer userid) {
        return this.orderFormDao.queryByUserId(userid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<OrderForm> queryAllByLimit(int offset, int limit) {
        return this.orderFormDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param orderForm 实例对象
     * @return 实例对象
     */
    @Override
    public OrderForm insert(OrderForm orderForm) {
        this.orderFormDao.insert(orderForm);
        return orderForm;
    }

    /**
     * 修改数据
     *
     * @param orderForm 实例对象
     * @return 实例对象
     */
    @Override
    public OrderForm update(OrderForm orderForm) {
        this.orderFormDao.update(orderForm);
        return this.queryById(orderForm.getOrderId());
    }

    /**
     * 通过主键删除数据
     *
     * @param orderId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer orderId) {
        return this.orderFormDao.deleteById(orderId) > 0;
    }

    @Override
    public int count() {
        return orderFormDao.count();
    }

    @Override
    public int updateOrderfor(String state, Integer orderId) {
        return orderFormDao.updateOrderfor(state,orderId);
    }

    @Override
    public int selectState(String state ,int userid) {
        return orderFormDao.selectState(state,userid);
    }

    @Override
    public int count1() {
        return orderFormDao.count1();
    }

    @Override
    public List<OrderForm> queryAllByLimit1(int offset, int limit, String state) {
        return orderFormDao.queryAllByLimit1(offset,limit,state);
    }


    @Override
    public int countLimit(Integer userid) {
        return orderFormDao.countLimit(userid);
    }

}